package net.lab1024.sa.user.module.business.mall.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.lab1024.sa.common.common.domain.PageResult;
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.user.common.UserBaseController;
import net.lab1024.sa.user.constant.UserSwaggerTagConst;
import net.lab1024.sa.user.module.business.mall.dao.GoodsDao;
import net.lab1024.sa.user.module.business.mall.domain.form.GoodsQueryForm;
import net.lab1024.sa.user.module.business.mall.domain.vo.GoodsVO;
import net.lab1024.sa.user.module.business.mall.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@RestController
@Api(tags = UserSwaggerTagConst.Business.GOODS)
public class GoodsController extends UserBaseController {

    @Autowired
    private GoodsService goodsService;

    @ApiOperation("分页查询")
    @PostMapping("/goods/query")
    @PreAuthorize("@saAuth.checkPermission('goods:query')")
    public ResponseDTO<PageResult<GoodsVO>> query(@RequestBody @Valid GoodsQueryForm queryForm) {
        return goodsService.query(queryForm);
    }


}
